package common.store.admin.contoller;


import common.store.admin.service.SupplierService;
import common.store.admin.service.impl.SupplierServiceImpl;
import common.store.web.bean.Supplier;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/supplierEdit")
public class SupplierEditServlet extends HttpServlet {
    private SupplierService supplierService;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        supplierService = new SupplierServiceImpl();
        String sid = req.getParameter("sid");
        System.out.println(sid+"--------");
        Supplier supplier = supplierService.getSupplierBySid(sid);
        if (null != supplier) {
            req.setAttribute("supplier", supplier);
            req.getRequestDispatcher("/admin/supplier/edit.jsp").forward(req, resp);
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
